<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    import="java.sql.*"
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Authentification</title>
</head>
<body>
<%
Connection conn=null;
Statement stmt=null;
try{
	Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
	System.out.print("la classe est introuvale");
	e.printStackTrace();
	}
try{
	String url="jdbc:mysql://localhost:3306/base_labrocante";
	String user="root";
	String pw="";
	
	String login=request.getParameter("t1");
	String pass=request.getParameter("t2");
	
	conn=DriverManager.getConnection(url,user,pw);
	stmt = conn.createStatement();
	String req1="select * from utilisateur where valider !=0 and login='"+login+"' and password='"+pass+"'";
	ResultSet rset=stmt.executeQuery(req1);
	if(rset.next()){
	String nomuser=rset.getString("nom");	
	int statut=Integer.parseInt(rset.getString("statut"));
	String iduser=rset.getString("idUtilisateur");
	response.sendRedirect("majVendeur.jsp");
	session.setAttribute("login",login);
	session.setAttribute("iduser",iduser);
	session.setAttribute("nomuser",nomuser);
	session.setAttribute("statut",statut);
	}
	else
	{
	response.sendRedirect("erreurAuthentif.html");
	}
	%>

<%
}
catch(SQLException e){
e.printStackTrace();
}
%>

</body>
</html>